Disk Controller Configured to Perform Out of Order Execution of Write Operations

ABSTRACT

A controller for a disk drive includes first memory storing first write operations and second write operations received in a first order. A processor arranges the first write operations and the second write operations in a second order based on respective track sectors associated with the first and the second write operations. The second order is different than the first order. A memory controller transfers write operation data corresponding to the first write operations and the second write operations to a disk formatter in the second order in response to a single command from the processor.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.12/338,013, filed Dec. 18, 2008, which is a continuation of U.S. patentapplication Ser. No. 11/509,285, filed Aug. 24, 2006, which is acontinuation of U.S. patent application Ser. No. 10/920,881 (now U.S.Pat. No. 7,103,715), filed Aug. 18, 2004, which is a continuation ofU.S. patent application Ser. No. 09/643,636 (now U.S. Pat. No.6,826,650), filed Aug. 22, 2000. The disclosures of the aboveapplications are incorporated herein by reference in their entirety.

FIELD

This invention relates generally to hard disk controllers and, moreparticularly, the invention relates to a disk controller and associatedmethods that enable multiple write operations to be executed out oforder during a single revolution of a disk.

BACKGROUND

The Background description provided herein is for the purpose ofgenerally presenting the context of the disclosure. Work of thepresently named inventors, to the extent it is described in thisbackground section, as well as aspects of the description which may nototherwise qualify as prior art at the time of filing, are neitherexpressly or impliedly admitted as prior art against the presentdisclosure.

The speed at which a hard disk drive executes read and write operationsrequested by a host computer is critical to the performance of thecomputer. Any delay caused by the hard disk drive will likely cause acorresponding delay in the execution of a program by the computer. Someof the developments in hard drive technology have focused on decreasingthe response time or increasing the data transfer rate for individualdisk operations. Other developments in hard drive technology havefocused on decreasing the amount of time that it takes to executemultiple operations. Two of the latter type of developments aredescribed in U.S. Pat. Nos. 4,667,286 and 6,029,226.

U.S. Pat. No. 4,667,286, titled “Method and apparatus for transferringdata between a disk and a central processing unit,” presents anarchitecture with toggling data buffers. The architecture allowsmultiple operations to be performed during a single revolution of thedisk. Data is transferred between the central processing unit and afirst data buffer while data is transferred between a second data bufferand the disk. The operation of the buffers can be toggled such that datais transferred between the central processing unit and the second databuffer while data is transferred between the first data buffer and thedisk.

U.S. Pat. No. 6,029,226, titled “Method and apparatus having automatedwrite data transfer with optional skip by processing two write commandsas a single write command,” presents a method for combining writecommands. The proximity of the first logical block address (LBA) of asecond write command is compared to the ending LBA of a first writecommand. If the second write command is sufficiently close, the diskcontroller executes the two write commands as a single write command,skipping over the sectors between the two commands during the combinedwrite. Two writes, therefore, can be performed in one revolution of thehard disk.

In certain instances, it would also be advantageous to execute writeoperations in an order other than the order in which the operations arereceived by the disk controller. Executing write operations out of ordermay allow the writes to be executed during a single rather than multiplerevolutions of the disk. The total time taken to execute the operationsis therefore reduced. The present invention seeks to provide thisadvantage, among others.

SUMMARY

A memory controller for a disk controller comprises a first memory thatreceives first and second write operations in a first order and thatstores the first and second write operations and corresponding writeoperation data. A second memory stores a corresponding address for eachof the write operations, wherein the corresponding addresses identify alocation of the write operation data stored in the first memory.Controller logic determines whether the first write operation and thesecond write operation write data to a same track of a disk andtransfers the write operation data from the first memory to a thirdmemory in a second order when the first write operation and the secondwrite operation write data to the same track, wherein the second orderis different from the first order.

Further areas of applicability of the present disclosure will becomeapparent from the detailed description provided hereinafter. It shouldbe understood that the detailed description and specific examples, whileindicating the preferred embodiment of the disclosure, are intended forpurposes of illustration only and are not intended to limit the scope ofthe disclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

The present disclosure will become more fully understood from thedetailed description and the accompanying drawings, wherein:

FIG. 1 illustrates a typical configuration of a computer system in whicha hard disk unit is utilized as a mass storage device of a host system;

FIG. 2 illustrates a typical configuration of a hard disk controller;

FIG. 3 illustrates the flow of data from the host system to the diskduring a typical disk write operation;

FIG. 4 illustrates the operation of a circular data buffer during writeoperations;

FIG. 5 illustrates a buffer memory controller and a disk formatter indetail;

FIG. 6 illustrates a method by which the hard disk controller typicallyhandles write operations;

FIG. 7 illustrates a schematic of a hard disk platter in conjunctionwith a write head;

FIG. 8 illustrates a preferred embodiment of a buffer memory controlleraugmented to perform non-sequential reads of a buffer memory through asingle command from a microprocessor;

FIGS. 9A and 9B illustrate preferred methods performed by the buffermemory controller to achieve combined write functionality for writeoperations received out of order;

FIGS. 10A and 10B illustrate a preferred method performed by the harddisk controller to complete multiple out of order operations using asingle set of commands to the buffer memory controller and the diskformatter; and

FIG. 11 illustrates a method of an example sequence of steps performedby the hard disk controller for two write operations that arrive out oforder.

DETAILED DESCRIPTION

The following description is merely exemplary in nature and is in no wayintended to limit the disclosure, its application, or uses. For purposesof clarity, the same reference numbers will be used in the drawings toidentify similar elements. As used herein, the phrase at least one of A,B, and C should be construed to mean a logical (A or B or C), using anon-exclusive logical or. It should be understood that steps within amethod may be executed in different order without altering theprinciples of the present disclosure.

In the following description, reference is made to the accompanyingdrawings, which form a part hereof, and which show, by way ofillustration, specific embodiments or processes in which the inventionmay be practiced. Where possible, the same reference numbers are usedthroughout the drawings to refer to the same or like components. In someinstances, numerous specific details are set forth in order to provide athorough understanding of the present invention. The present invention,however, may be practiced without the specific details or with certainalternative equivalent components and methods to those described herein.In other instances, well-known methods and components have not beendescribed in detail so as not to unnecessarily obscure aspects of thepresent invention.

I. HARD DISK CONTROLLER OPERATION A. Computer System

FIG. 1 illustrates a typical configuration of a computer system in whicha hard disk unit 110 is utilized as a mass storage device of a hostsystem 120. The host system 120 is preferably the motherboard of thecomputer system and typically includes a system bus 122 that connectsone or more microprocessors, RAM, and possibly other components. Thehard disk unit 110 typically includes a hard disk controller 112 thatcontrols a disk 114. The disk 114 typically includes several platters ofrotating magnetic media that are read from and written to by read andwrite heads (not illustrated). In the illustrated embodiment, the harddisk controller 112 is connected to the host system through an AdvancedTechnology Attachment (ATA) bus 116. The ATA bus 116 is in turnconnected to the host system bus 122 through an I/O bus bridge adapter124. The adapter 124 serves as a bridge between the different protocolsand technologies of the host system bus 122 and the ATA bus 116.Alternative technologies, such as SCSI, USB, or Firewire may also beused in place of the ATA bus 116.

The host system 120 typically sends read and write operations to thehard disk controller 112 via the ATA bus 116. A read operation typicallyidentifies the requested data by the location on the disk of thebeginning logical block address (LBA) of the data. The LBA specifies thehead, track, and sector number of a block (512K) of data. A sectortypically holds one block of data. The request causes the hard disk unit110 to respond by reading and transmitting the requested data back tothe host system 120 via the ATA bus 116. A write operation typicallyidentifies the starting LBA of the location on the disk to be written.Data is transferred from the host system 120 to the hard disk controller112 and is written to the disk starting at the specified LBA.

B. Hard Disk Controller

FIG. 2 illustrates a typical configuration of a hard disk controller112. The hard disk controller 112 typically includes a microprocessor204, a set of firmware code 205, a buffer memory 206, and a hard diskcontroller core 210. The controller core 210 handles the flow of databetween the ATA bus 116 and the disk 114. The controller's taskstypically include transferring data between the disk 114 and the buffermemory 206, transferring data between the buffer memory 206 and the ATAbus 116, and performing error correction and CRC calculations. Theoperation of the controller core 210 is in turn controlled by thecontroller microprocessor 204, which typically executes the set offirmware code 205. The firmware code 205 may be stored in nonvolatilememory. The microprocessor may also have an additional interface (notillustrated) to the disk 114 to handle tasks such as moving theread/write heads of the disk 114 to the proper track. The buffer memory206 is used to buffer data between the disk 114 and the ATA bus 116 tocompensate for delays, latency, and timing differences between the twodevices. In some configurations, the buffer memory 206 also serves asthe memory for the controller microprocessor 204. The size of the buffermemory 206 may range from 256 kilobytes to 8 megabytes, depending uponthe application.

The controller core 210 typically includes an ATA bus interface 220, abuffer memory controller 230, and a disk formatter 240. The ATA businterface 220 implements the ATA bus protocol to receive writeoperations and read operations and to send read data to the host system120. A write operation 222 is shown in dashed lines to indicate that itpasses through the bus interface 220. The LBA of the write operation istypically read by the microprocessor 204 and stored. The bus interface220 passes the data to the buffer memory 206 through the buffer memorycontroller 240.

The buffer memory controller 230 controls interleaved access to thebuffer memory 206 by the ATA bus interface 220, the disk formatter 240,and the microprocessor 204. The control of the buffer memory 206 by thebuffer memory controller 230 typically involves arbitrating access bythe various units as well as buffering data, yet again, between thebuffer memory 206 and the units that access it. The buffer memorycontroller 230 typically includes an ATA bus interface data FIFO (firstin, first out buffer) 232 that buffers data between the ATA businterface 220 and the buffer memory 206, a disk formatter data FIFO 234that buffers data between the buffer memory 206 and the disk formatter240, and buffer controller logic 236 that controls the functionality ofthe buffer controller 230. The buffer controller 230 typically storeswrite operation data in a circular data buffer 208 that the buffercontroller 230 implements within the buffer memory 206, preferably usingpointers. The ATA bus interface data FIFO 232 and the disk formatterdata FIFO 234 are relatively small FIFO buffers, preferably about 64bytes each. The circular data buffer 208, on the other hand, ispreferably much larger, possibly occupying the whole buffer memory 206,which may be 256 kilobytes to 8 megabytes in some embodiments.

The disk formatter 240 controls the actual writing of data to the disk114. The disk formatter 240 typically receives data from the buffermemory 206 through the buffer memory controller, formats the data forwriting to the disk, possibly adding error correction codes, and sendsthe data to the write head of the disk. The disk formatter 240 alsomonitors the sector of a track over which the disk's read/write head ispositioned to determine the proper timing for sending the data to thewrite head. The functionality of the disk formatter is controlled bydisk formatter logic 242.

FIG. 3 illustrates the flow of data from the host system 120 to the disk114 during a typical disk write operation. The data is first transferredfrom the host system 120 via the ATA bus 116 to the ATA bus interface220 of the hard disk controller 112. The ATA bus interface 220, in turn,transfers the data through the ATA bus interface FIFO 232 of the buffermemory controller 230 to the circular data buffer 208 in the buffermemory 206. The data remains in the circular data buffer 208 until it isto be written to the disk 114. If the disk heads have been correctlypositioned and the microprocessor 204 has determined that the data isready to be written to disk 114, the microprocessor 204 issues a commandto the buffer controller 230 to begin transferring the data into thedisk formatter data FIFO 234. The microprocessor 204 also issues acommand to the disk formatter 240 to begin reading the data from thedisk formatter data FIFO 234, formatting the data, and sending the datato the write head of the disk 114. A disk formatter command typicallyonly instructs the disk formatter 240 to write data to one track on thedisk. In the case of a large write operation, for example, on the orderof several megabytes, earlier data already placed in the circular databuffer 208 is read by the disk formatter 240 while later data for thesame operation is being written to the circular data buffer 208 by theATA bus interface 220. If the write operation involves writing tomultiple tracks, after the disk formatter 240 writes data to each track,the microprocessor 204 moves the write head to the next track and issuesan additional command to the disk formatter 240 to write data to thenext track.

FIG. 4 illustrates the operation of the circular data buffer 208 duringwrite operations. In the illustrated example, the data of three writeoperations have been written to the buffer memory 206 by the ATA businterface 220. The buffer memory controller 230 updates a write pointer402 to indicate the address within the buffer memory 206 at which thecontroller writes incoming data from the ATA bus interface 220. As datais written, the pointer 402 is updated. If the write pointer 402 reachesthe end of the circular buffer 208, the pointer 402 is wrapped around tothe other end to effect the circular buffer functionality. A readpointer 404 indicates the address at which data is read from thecircular buffer 208 to be transferred to the disk formatter 240. In theillustrated example, the data of the three write operations in thebuffer 208 has not yet been transferred to the disk formatter 240. Asdata is read, the default operation of the buffer memory controllerlogic 236 advances the read pointer 404 within the circular buffer 208.The read pointer is eventually wrapped around like the write pointer. Inone embodiment, as long as the buffer controller is not reset, the readpointer 404 will continually advance through the data of write operationafter write operation as long as the disk formatter 234 continues toread the data from the disk formatter data FIFO 234. The write pointer404 typically will not, however, advance past the read pointer 402.

FIG. 5 illustrates the buffer memory controller 230 and the diskformatter 240 in greater detail. The buffer memory controller 230includes a disk formatter (DF) buffer address register 502 in which theread pointer 404 is maintained during write operations. Typically, thebuffer address register 502 is initially loaded by the microprocessor204. The buffer memory controller logic 236, however, automaticallyadvances the buffer address register 502 as data is transferred to thedisk formatter data FIFO 234.

The disk formatter 240 typically includes a sector requested register512, a sector count register 514, and a set of skip sector registers516. The microprocessor 204 initiates a disk operation by loading thesector requested register 512, the sector count register 514, and theskip sector registers 516 with the appropriate values and by issuing acommand to the disk formatter 240. The sector requested register 512 isloaded with the sector number of the first sector on the track to bewritten in conjunction with the command. The sector count register 514is loaded with the number of sectors to be written during the operation.There are typically 8 skip sector registers 516. Each skip sectorregister 516 typically contains a 10-bit sector 1D field and a 4-bitlength field to identify unique sectors that are to be skipped duringthe execution of a command. Sectors are typically skipped because theyare defective. The 4-bit length field provides a range value startingfrom the sector pointed to by the ID field. The range value is set tozero when the skip register is not valid. Access to the skip sectorregisters 516 is through a single FIFO-like interface. The skip sectorregisters 516 must be loaded in ascending order. During commandexecution, the sector requested register 512 is compared with the skipsector registers to determine if the sector is to be skipped. Skippedsectors are not counted as part of the sector count.

C. Typical Method for Handling Write Operations

FIG. 6 illustrates a method 600 by which the hard disk controller 112handles write operations. At a step 602, the ATA bus interface 220 ofthe hard disk controller 112 receives a write operation 222 from thehost system 120. The write operation 222 typically includes the data tobe written to disk and an LBA identifying the starting location on thedisk to which the data is to be written.

At a step 604, the ATA bus interface 220 sends the data to the circulardata buffer 208 of the buffer memory 206. In order to send the data tothe buffer memory 206, the ATA bus interface 220 writes the data to theATA bus interface FIFO 232 of the buffer memory controller 230. Thebuffer memory controller 230, in turn, maintains the write pointer 402of the circular data buffer 208 and writes the data to the buffer memory206. The buffer memory controller 230 interleaves the writing of thedata from the ATA bus interface FIFO 232 with other reads and writesfrom the disk formatter data FIFO 234, for example, and other units thataccess the buffer memory, such as the controller microprocessor 204.

At a step 606, the microprocessor 204 reads the LBA from the ATA businterface 220 and stores the LBA of the write operation 222. Thecontroller microprocessor 204 typically uses a portion of the buffermemory 206 as its working memory. The microprocessor 204 may, in thiscase, store the LBA in the buffer memory 206, accessing the buffermemory through the buffer memory controller 230. Before control proceedsto the remaining steps of the method 600, additional write operationsmay be received by the ATA bus interface 220 and handled by themicroprocessor 204 as indicated by the arrow leading from the step 606to the step 602.

At a step 608, the microprocessor 204 decides to execute a receivedwrite operation. The microprocessor 204 is preferably programmed by thefirmware code 205 in accordance with known techniques in order todetermine when to execute the operation.

At a step 610, the microprocessor 204 loads the disk formatter bufferaddress register 502 with the beginning address of the write operationdata within the buffer memory 206. At a step 612, the microprocessor 204completes programming of the buffer controller 204 for the writeoperation. This step may involve clearing the disk formatter data FIFO234 of any stale data and/or loading a command into a command registerof the buffer memory controller 230.

At a step 614, the buffer memory controller 230 begins to transfer datafrom the buffer memory 206 to the disk formatter data FIFO 234. As thedisk formatter 240 reads the data from the FIFO 234, the buffer memorycontroller 230 writes data to the FIFO 234 to keep the FIFO 234 fromunderflowing.

At a step 616, the microprocessor 204 programs any additional componentsnecessary to move the write head of the disk 114 to the proper track.The circuits that control the movement of the write head are preferablyexternal to the controller core 210 but may be included in the core 210.The step 616 may alternatively be performed between the steps 610 and608.

At a step 618, the microprocessor 204 loads the sector requestedregister 512 of the disk formatter 240 with the sector 11) of the firstsector of the write operation to be written to the track. At a step 620,the microprocessor 204 loads the sector count register 514 with thenumber of sectors to be written to the track. In the case a writeoperation spans multiple tracks, the number of sectors that are writtento the track may be less than the number of blocks in the entireoperation. In this case, the disk formatter 240 is later programmed towrite data to the subsequent tracks after the write to the present trackhas been completed.

At a step 622, the microprocessor 204 loads the skip sector registers516 with data identifying defective sectors on the track to be skippedduring the write to the track. At a step 624, the microprocessor 204completes programming of the disk formatter 240 for the write to thetrack. This step typically includes loading a command into a commandregister of the disk formatter 240.

At a step 626, the disk formatter 240 begins execution of the commandloaded into its command register by the microprocessor 204. The diskformatter 240 reads data from the disk formatter data FIFO 234, formatsthe data for writing to the disk 114, and sends the data to the writehead of the disk 114. The formatting of the data for writing to the disk114 may involve adding a cyclic redundancy check (CRC) code to the data.The disk formatter 240 typically also determines the proper timing forsending the data to the write head of the disk 114 so that the data iswritten to the proper location on the track.

At a step 628, the disk formatter 240 completes the writing of the lastsector to the current track. At a step 630, the disk formatter 240 sendsan interrupt to the controller microprocessor 204 and indicates thesuccess status of the write to the track. Typically the write will havebeen successful. If the write was unsuccessful, the microprocessor withthen handle the problem.

At a step 632, the microprocessor determines whether there is more datato be written to another track in conjunction with the present writeoperation. If additional data remains to be written to another track,control passes back to the step 616. From the step 616, themicroprocessor moves the write head to the next track and programs thedisk formatter 240 to write more data to the next track.

At the step 632, if the current write operation has completed because nomore data remains to be written to another track, the hard diskcontroller 112 is ready to handle the receipt or execution of anotherwrite operation. Accordingly, control passes to either the step 602 orthe step 608, possibly depending upon whether another write operationhas already been received.

D. Combining Write Operations to Improve Performance

In one embodiment, the microprocessor 204 may be programmed to completetwo or more write operations with only a single command to the buffermemory controller 230. The buffer memory controller need not bereprogrammed as in the steps 610-614 as long as the data from the secondwrite operation is written contiguously after the data of the firstwrite operation within the circular data buffer 208 before the firstoperation completes. The buffer memory controller 230 is preferablyconfigured to continue supplying data from circular data buffer 208 tothe disk formatter data FIFO 242 as long as the disk formatter 240 keepsreading the data. Accordingly, the buffer memory controller 230 willcontinue to supply data to the disk formatter data FIFO 234 from thecircular data buffer 208 as the last of the data of the first writeoperation is read by the disk formatter 240 and written to disk. Thedata that the buffer memory controller 230 automatically supplies torefill the FIFO 234 will be the data of the second write operation. Inthis instance, therefore, the buffer memory controller 230 need not bereprogrammed, and the steps 610-614 of the process 600 can be skipped.

In one embodiment, the microprocessor 204 may also be programmed topartially or completely write data from two write operations using asingle command to the disk formatter 240. A single command to the diskformatter can be used when the ending LBA of an earlier operation hasthe same track but a lower sector number than the beginning LBA of thesubsequent operation. In this case the microprocessor can treat the twooperations as a single operation by instructing the disk formatter 240to skip the sectors between the two operations. This can be accomplishedby loading one or more of the skip sector registers 516 with theregisters to be skipped between the write operations.

The aforementioned techniques allow the programming of the buffercontroller 230 and/or the disk formatter 240 for two or more writeoperations to be combined. One advantage to combining the programming ofthe disk formatter 240 for two or more write operations is that thewrite operations will be completed in a single revolution.

The microprocessor 204 typically has a much longer response time and ismuch slower than the disk formatter 240 to react. There is typically notenough time after the disk formatter 240 interrupts the microprocessor204 upon completion of a write operation to allow the microprocessor 204to reprogram the disk formatter 240 for a second write operation withoutlosing a revolution of the disk 114. Accordingly, in order to completemore than one write operation during a single revolution of the disk114, the two or more write operations must be completed through a singlecommand to the disk formatter 240. In order to combine the programmingof the disk formatter 240 for the two or more operations the programmingof the buffer controller 230 for these operations must also be combined.This is the case since the microprocessor 204 is also typically not fastenough to reprogram the buffer controller 230 between write operations.

As already mentioned, the controller microprocessor 204 is generally notfast enough to reprogram the buffer memory controller 230 or the diskformatter 240 between the write operations. In addition, some diskformatters may be configured to begin execution of each command bysearching for the first sector on a track, such as, for example, tobegin a timing sequence for writing the data. In such cases, the diskformatter 240 will nevertheless be able to execute only one command perrevolution, regardless of the speed of the microprocessor 204.Accordingly, if several write operations that write data to the sametrack on a disk are to be executed in a single revolution, the writeoperations must typically be completed through a single command to eachof the buffer controller 230 and the disk formatter 240.

Executing more than one write operation in a single revolution of thedisk 114 substantially speeds up the execution of the writes. Forexample, if two writes are executed in a single revolution, executiontime can be decreased to as little as ½ of the time of separatelyexecuting the writes. If four writes are executed in a singlerevolution, execution time will be at most 113 and as little as 114 ofthe time of executing the writes separately

E. Limitations of the Aforementioned Techniques

Although the aforementioned techniques can be used to decrease the timeto perform several write operations in certain instances, in otherinstances, these techniques cannot be used. For example, if the order inwhich the write operations arrive does not correspond to the order ofthe respective write operations on the disk, these techniques cannot beused.

FIG. 7 illustrates a schematic of a hard disk platter 702 in conjunctionwith a write head 704. The disk 702 is indicated as rotating in thecounter-clockwise direction. Also illustrated are the sectors of threeseparate write operations (write 1, write 2 and write 3) to one of thetracks 704 of the platter 700. The sectors of the operations pass underthe write head 704 such that the operation 3 passes the head 704 first,the operation 2 passes second, and the operation 1 passes third. Supposethe write operation 1 arrives at the hard disk controller 112 first, theoperation 2 arrives second, and the operation 3 arrives third. The writeoperations will be stored in the buffer memory in this same sequence asillustrated in FIG. 4. Accordingly, the order in which the operationsare stored in the circular data buffer 208 does not correspond to theorder of the operations' sectors on the track 704. As a result, a singlecommand cannot be used to program the buffer memory controller 230 tosupply the data of the respective operations in the proper order to bewritten to disk.

The buffer memory controller 230 described above is only configured tobe able to supply data, through a single command, in the same order inwhich the data is located in the circular data buffer 208. Consequently,if any two operations are out of order within any sequence of writeoperations to the same track, the data of the sequence of operationscannot be provided using a single buffer controller command.

As will be shown in the preferred embodiment below, the buffercontroller 240 can be augmented with additional components that allow itto supply data from different sections of the circular data buffer 208in non-sequential order using a single command from the microprocessor204.

II. PREFERRED EMBODIMENT A. Augmented Buffer Memory Controller and DiskFormatter

FIG. 8 illustrates a preferred embodiment of a buffer memory controller830 augmented to perform non-sequential reads from the buffer memory 206through a single command from the microprocessor 204. The buffer memorycontroller 830 preferably includes all of the components illustrated inFIG. 5 of the buffer memory controller 230. The buffer memory controller830 also preferably includes a set of address registers 852, a workingdisk formatter buffer address register 802, a set of block countregisters 862, a working block count register 864, a busy flag 854, andcombined write logic 870.

There are preferably 8 or more registers in the set of address registers852. Although 4, 3, or 2 address registers could be used, this wouldlimit the number of write operations that could be written through asingle set of commands to the buffer memory controller 830 and the diskformatter 240. The microprocessor 204 loads each of the addressregisters 852 with the starting address of the data in the buffer memory206 for one of the write operations to be written to the track. Theaddress registers 852 are loaded in the order in which the writeoperations are to be performed. The address registers 852 are preferablyconfigured to be written to by the microprocessor 204 through aFIFO-like interface, similar to the skip sector registers 516. Each ofthe addresses in the set of address registers 852 is eventuallytransferred into the working disk formatter buffer address register 802during execution of the write operations. The working address register802 functions substantially in the same way as the buffer addressregister 502.

The number of block count registers 862 matches the number of addressregisters 852. The microprocessor 204 loads each of the block countregisters 862 with the number of blocks of data stored in the buffermemory 206 to be written to the track for the corresponding writeoperation. The block count registers 862 are loaded in the order inwhich the write operations are to be performed. Like the addressregisters 852, the block count registers 862 are preferably configuredto be written to by the microprocessor 204 through a FIFO-likeinterface, similar to the skip sector registers 516. Each of the blockcounts in the block count registers 862 is eventually transferred intothe working block count register 864 during the execution of the writeoperations. The working block count register 864 is used to count downthe number of blocks remaining to be transferred as they are transferredfrom the buffer memory 206 to the disk formatter data FIFO 234 for eachoperation.

The busy flag 854 is preferably a register or a bit in a register thatcan be read by the microprocessor 204 to determine whether the addressregisters 852 and the block count registers 862 are full. If theregister sets 852 and 862 are full, the bit is set. If the register sets852 and 862 are not full, the bit is cleared.

The combined write logic 870 is preferably added to the buffer memorycontroller logic 236 to control the functionality of the block countregisters 862, the address registers 852, the working block countregister 864, the busy flag 854. The logic 870 controls these elementsto transfer the data of multiple write operations to the disk formatterdata FIFO 234 from a single command supplied by the microprocessor 204regardless of the order of the operations' data in the buffer memory206.

The disk formatter 240 of the preferred embodiment is substantiallyunmodified. The number of skip sector registers 516, however, ispreferably increased. In the preferred embodiment, 16 skip sectorregisters 516 are included instead of 8 to handle the extra sector skipsbetween the two or more write operations on the same track.

B. Buffer Memory Controller Methods

FIGS. 9A and 9B illustrate preferred methods 900 and 950 performed bythe controller 830 under the control of the combined write logic 870 andthe buffer memory controller logic 236 to achieve the combined writefunctionality for write operations received out of order. The methods900 and 950 may be performed simultaneously, preferably in aninterleaved fashion. The method 900 sets the busy flag 854, while themethod 950 manipulates the working buffer address 802 and working blockcount 864 registers.

At a step 902 of the method 900, the buffer memory controller 830receives data in the address registers 852 and the block count registers862. At a step 904, the controller 830 determines whether the addressand block count registers 852 and 862 are all full. If the registers 852and 862 are full, the controller 830 sets the busy flag 854. If theregisters 852 and 862 are not full, the controller 830 passes controlback to the step 902.

At a step 952 of the method 950, the buffer memory controller 830receives a command from the microprocessor 204 that selects the use ofthe address registers 852 and the block count registers 862 to transferthe data of multiple operations. The use of these registers 852 and 862is preferably made an option to the microprocessor 204, the option mayonly be selected when the operations to be combined have arrived out oforder.

At a step 954, the buffer memory controller 830 transfers an address ofdata for a write operation from the address registers 852 into theworking address register 802. The addresses are transferred from theaddress registers 852 in the order in which the address registers 852were loaded by the microprocessor 204. In other words, the addressregisters 852 preferably have a FIFO functionality. At a step 956, thecontroller 830 transfers a block count for a write operation from theblock count registers 862 into the working block count register 864. Theblock count registers 862 also have a FIFO functionality. At a step 858,the controller clears the busy flag since at least one location in eachof the sets of registers 852 and 862 has just been emptied.

At a step 960, the controller 830 begins transferring data from thebuffer memory 206 to the disk formatter data FIFO 234, starting at theaddress in the working address register 802. The controller preferablyuses the working address register 802 as a read pointer and incrementsthe register 802 as it reads data from the buffer memory 206.

At a step 962, the controller 830 decrements the working block countregister 864 upon initiating the transfer of each block (512K) of datafrom the buffer memory 206 to the disk formatter data FIFO 234.

At a step 964, the controller 830 waits for the working block countregister 864 to reach zero. This indicates that the last block of theoperation has begun to be transferred from the buffer memory 206 to thedisk formatter data FIFO 234. At a step 966, the controller 830transfers the last block of data for the operation and then stopstransferring data. At this point control passes back to the step 954,and the data of the next write operation is transferred.

The process 950 continues until all of the entries in the addressregisters 852 and the block count registers 862 have been processed.Once all of the entries have been processed, the controller 830 is readyto receive another command from the microprocessor 204.

C. Hard Disk Controller Method

FIGS. 10A and 10B illustrate a preferred method 1000 performed by thehard disk controller 112 to complete multiple out of order operationsusing a single set of commands to the buffer memory controller 830 andthe disk formatter 240. The microprocessor 204 is preferably programmedwith the firmware 205 to perform the method 1000. The steps 1002, 1004,and 1006 are substantially the same as the steps 602, 604, and 606 ofthe method 600.

At a step 1008, the microprocessor 204 identifies two or more writeoperations that write data to the same track, where one or more of theoperations arrive out of order with respect to the locations of thecorresponding sectors on the track. At a step 1010, the microprocessor204 orders the operations based upon the locations of their respectivesectors on the track.

At a step 1012, the microprocessor 204 loads the address registers 852with the beginning addresses in the buffer memory 206 of the data blocksof the write operations. In the preferred embodiment, the addressregisters 852 are written through a FIFO-like interface, which maintainsthe order in which the addresses are written. Accordingly, the addressesof the data blocks are loaded in the order, (determined by themicroprocessor 204 in the step 1010) in which the corresponding writeoperations are to be written to the track. At a step 1014, themicroprocessor loads the block count registers 862 with thecorresponding number of data blocks for each write operation in the samemanner.

At a step 1016, the microprocessor 204 completes programming the buffermemory controller 830. The programming preferably includes issuing acommand to the buffer memory controller 830 instructing it to transferdata based upon the addresses and block counts loaded in the addressregisters 852 and the block count registers 862. The microprocessor 204preferably also has the option of programming the buffer memorycontroller 830 to perform a regular data transfer in accordance with themethod 600.

At a step 1018, the buffer memory controller 830 begins to transfer dataof the write operations from the buffer memory 206 to the disk formatterFIFO 234. As the disk formatter 240 reads the data from the FIFO 234,the buffer memory controller 830 writes data to the FIFO 234 to keep theFIFO 234 from underflowing.

At a step 1020, the microprocessor 204 programs any additionalcomponents necessary to move the write head of the disk 114 to theproper track. The step 1020 may alternatively be performed between thesteps 1012 and 1010.

At a step 1022, the microprocessor 204 loads the sector requestedregister 512 of the disk formatter 240 with the sector 1D of the firstsector of the first write operation to be written to the track. At astep 1024, the microprocessor 204 loads the sector count register 514with the total number of sectors to be written to the track for all ofthe identified operations.

At a step 1026, the microprocessor 204 loads the skip sector registers516 with data identifying sectors on the track to be skipped betweenwrite operations. The registers are also loaded with the defectivesectors on the track to be skipped during the writes. At a step 1028,the microprocessor 204 completes programming of the disk formatter 240for the write to the track. This step typically includes loading acommand into a command register of the disk formatter 240.

At a step 1030, the disk formatter 240 begins execution of the commandloaded into its command register by the microprocessor 204. The diskformatter 240 reads data from the disk formatter data FIFO 234, formatsthe data for writing to the disk 114, and sends the data to the writehead of the disk 114.

At a step 1032, the buffer memory controller 830 supplies data from thesuccessive write operations according to the addresses and block countsloaded in the address registers 852 and the block count registers 862.The buffer memory controller 830 preferably performs the method 950 inthis step.

At a step 1034, the disk formatter 240 completes the writing of the lastsector to the current track. At a step 1034, the disk formatter 240sends an interrupt to the controller microprocessor 204 and indicatesthe success status of the write to the track.

In the case that all of the write operations are completely on a singletrack, the method ends at this point and the hard disk controller 112 isprepared to perform additional write operations. Alternatively, themethod 1000 may also be used when the first write operation and/or thelast write operation to be executed span two or more tracks. Forexample, a short write operation to a track may arrive before a longeroperation that ends on the same track. The latter operation can beexecuted first and followed by the first operation using a single buffermemory controller command. A single disk formatter command can be usedto write the last portion of the latter command's data and all of theformer command's data. In the case one or more write operations span twotracks, the method 1000 continues as described below.

At a next step 1036, the microprocessor determines whether there is moredata to be written to another track in conjunction with the present setof write operations. If additional data remains to be written to anothertrack, control passes back to the step 1020. From the step 1020, themicroprocessor moves the write head to the next track and programs thedisk formatter 240 to write more data to the next track.

At the step 1038, if the current set of write operations has completedsince there remains no more data to be written to another track, thehard disk controller 112 is ready to handle the receipt or execution ofanother set of write operations. Accordingly, control passes to eitherthe step 1002 or the step 1008, possibly depending upon whether anotherwrite operation has already been received.

D. Example Operation

FIG. 11 illustrates a method 1100 of an example sequence of stepsperformed by the hard disk controller 112 for two write operations thatarrive out of order. The method 1100 illustrates in more specific detailfor the case of two write operations, the steps 1002 through 1014 of themethod 1000.

At a step 1102, the ATA bus interface 220 receives a first writeoperation. At a step 1104, the buffer memory controller 230 writes thedata of the first write operation to the circular data buffer 208. At astep 1106, the bus interface 220 receives a second write operation. At astep 1108, the buffer memory controller 230 writes the data of thesecond write operation to the circular data buffer 208 after the data ofthe first write operation. The data of the second write operation maybut need not be contiguous with the data of the first write operation inthe buffer memory 206.

At a step 1110, the microprocessor 204 determines that the second writeoperation writes to the same track as the first write operation. Themicroprocessor 204 preferably also determines that there are no commonlywritten sectors between the two write operations to avoid creating staledata. If the two operations involve a common sector, then the operationsshould be written in the order in which they arrive.

At a step 1112, the microprocessor 204 determines that the second writeoperation is located before the first write operation on the track. Themicroprocessor preferably makes this determination by comparing thesector numbers of the first sector that each operation writes. The orderof the operations is determined relative to the position where the writehead is capable of first writing to the track. In some embodiments, thedisk formatter 240 may be configured to be able to first write data toany sector on the track. If the head arrives at a track with 1024sectors and stabilizes itself while the head is over the 511th sector,for example, these embodiments may be configured to be able to writedata to the 512th sector during the current revolution of the disk. Inthis case, if the first write operation writes to sector 127 and thesecond operation writes to sector 575, the second write operation islocated before the first write operation on the track. In otherembodiments, the disk formatter 240 may be configured to wait for anddetect the 0th sector on a track before writing any data. In theseembodiments, even if the head stabilizes itself over the 511th sector ofa track with 1024 sectors, the disk formatter must wait until the 0thsector passes below the head before any data is written. In this case,if the first write operation writes to sector 575 and the second writeoperation writes to sector 127, the second write operation is locatedbefore the first write operation on the track.

In one embodiment, the steps 1110 and 1112 can be combined by comparingthe starting and ending sector numbers of each write operation. In thiscase, both operations must also write to the same track. In addition,supposing the disk formatter 240 must wait for the 0th sector to passbefore writing data, the ending sector number of the second operationmust be less than the starting sector number of the first operation. Itwill be apparent to one skilled in the art how to handle the case wherethe disk formatter 240 need not wait for the 0th sector to pass beforebeginning an operation.

At a step 1114, the microprocessor 204 loads one of the addressregisters 852 with the address of the data of the second write operationin the circular data buffer 208. At a step 1116, the microprocessor 204loads one of the block count registers 862 with the number of datablocks in the second write operation. At a step 1118, the microprocessor204 loads one of the address registers 852 with the address of the dataof the first write operation in the circular data buffer 208. At a step1120, the microprocessor 204 loads one of the block count registers 862with the number of data blocks in the first write operation.

Once the buffer memory controller 830 has been loaded with the addressesand block counts of the two operations, the method 1100 continues at thestep 1016 of the method 1000.

E. Extensions and Additional Embodiments

The method 1100 can be generalized by one skilled in the art into thefirmware code 205 to handle several write operations. The generalizedfirmware 205 can be configured to program the buffer memory controller830 to provide data of multiple write operations to the disk formatter240 regardless of the order in which the operations are received.

The number of operations that can be handled through a single command tothe buffer memory controller 830 may be limited by the number ofregisters in the address registers 852 and the block count registers862. In the preferred embodiment, however, these sets of registers 852and 862 can be written by the microprocessor 204 while the buffer memorycontroller 830 is executing a command. This functionality allows apotentially infinite number of out of order write operations to behandled with a single command to the buffer controller 830.

III. CONCLUSION

Although the invention has been described in terms of certain preferredembodiments, other embodiments that are apparent to those of ordinaryskill in the art, including embodiments which do not provide all of thefeatures and advantages set forth herein, are also within the scope ofthis invention. Accordingly, the scope of the invention is defined bythe claims that follow. In the claims, a portion shall include greaterthan none and up to the whole of a thing. In the method claims,reference characters are used for convenience of description only, anddo not indicate a particular order for performing the method.

1. A controller for a disk drive, the controller comprising: firstmemory that stores first write operations and second write operationsthat are received in a first order; a processor that arranges the firstwrite operations and the second write operations in a second order basedon respective track sectors associated with the first and the secondwrite operations, the second order being different from the first order;and a memory controller that transfers write operation datacorresponding to the first write operations and the second writeoperations to a disk formatter in the second order in response to asingle command from the processor.